package com.zhangmeng.tools.languages;

import java.util.regex.Pattern;

/**
 * @author : 芊芊墨客
 * @version : 1.0
 * @date : 2023-06-01 11:01
 */
public class ProcessJava {

    public static final String[] KEYWORDS = new String[] {
            "abstract", "assert", "boolean", "break", "byte",
            "case", "catch", "char", "class", "const",
            "continue", "default", "do", "double", "else",
            "enum", "extends", "final", "finally", "float",
            "for", "if", "goto", "implements", "import",
            "instanceof", "int", "interface", "long", "native",
            "new", "package", "private", "protected", "public",
            "return", "short", "static", "strictfp", "super",
            "switch", "synchronized", "this", "throw", "throws",
            "transient", "try", "void", "volatile", "while"
    };

    public static final String KEYWORD_PATTERN = "\\b(" + String.join("|", KEYWORDS) + ")\\b";
    public static final String PAREN_PATTERN = "\\(|\\)";
    public static final String BRACE_PATTERN = "\\{|\\}";
    public static final String BRACKET_PATTERN = "\\[|\\]";
    public static final String SEMICOLON_PATTERN = "\\;";
    public static final String STRING_PATTERN = "\"([^\"\\\\]|\\\\.)*\"";
    public static final String COMMENT_PATTERN = "//[^\n]*" + "|" + "/\\*(.|\\R)*?\\*/";
    public static final String ANNOTATION_PATTERN = "@[a-zA-Z]+";
    public static final String PARAMS_PATTERN = "\\\\b([a-zA-Z]+)\\\\s*=\\\\s*([a-zA-Z0-9]+)\\\\b";
    public static final String METHOD_PATTERN  = "\\w+\\((\\w+,\\s*)*\\w*\\)";

    public static final Pattern PATTERN = Pattern.compile(
            "(?<KEYWORD>" + KEYWORD_PATTERN + ")"
                    + "|(?<PAREN>" + PAREN_PATTERN + ")"
                    + "|(?<BRACE>" + BRACE_PATTERN + ")"
                    + "|(?<BRACKET>" + BRACKET_PATTERN + ")"
                    + "|(?<SEMICOLON>" + SEMICOLON_PATTERN + ")"
                    + "|(?<STRING>" + STRING_PATTERN + ")"
                    + "|(?<COMMENT>" + COMMENT_PATTERN + ")"
                    + "|(?<ANNOTATION>" + ANNOTATION_PATTERN + ")"
                    + "|(?<PARAMS>" + PARAMS_PATTERN + ")"
                    + "|(?<METHOD>" + METHOD_PATTERN + ")"

    );

   public static String SAMPLE_CODE = "package com.dashidao.server.model;\n" +
            "\n" +
            "import java.util.Date;\n" +
            "\n" +
            "public class PosterGroupCouponCode extends BaseEntity<Long> {\n" +
            "\n" +
            "\tprivate Date addTime;\n" +
            "\tprivate Boolean deleteStatus;\n" +
            "\tprivate String groupCouponCode;\n" +
            "\tprivate Integer groupCouponStatus;\n" +
            "\tprivate Date writeOffTime;\n" +
            "\tprivate Long orderFormId;\n" +
            "\tprivate Long posterGoodsCartId;\n" +
            "\tprivate Long tuiKuanShouHouId;\n" +
            "\tprivate Long orderMealUserId;\n" +
            "\tprivate String groupSkusJson;\n" +
            "\n" +
            "\tpublic Date getAddTime() {\n" +
            "\t\treturn addTime;\n" +
            "\t}\n" +
            "\tpublic void setAddTime(Date addTime) {\n" +
            "\t\tthis.addTime = addTime;\n" +
            "\t}\n" +
            "\tpublic Boolean getDeleteStatus() {\n" +
            "\t\treturn deleteStatus;\n" +
            "\t}\n" +
            "\tpublic void setDeleteStatus(Boolean deleteStatus) {\n" +
            "\t\tthis.deleteStatus = deleteStatus;\n" +
            "\t}\n" +
            "\tpublic String getGroupCouponCode() {\n" +
            "\t\treturn groupCouponCode;\n" +
            "\t}\n" +
            "\tpublic void setGroupCouponCode(String groupCouponCode) {\n" +
            "\t\tthis.groupCouponCode = groupCouponCode;\n" +
            "\t}\n" +
            "\tpublic Integer getGroupCouponStatus() {\n" +
            "\t\treturn groupCouponStatus;\n" +
            "\t}\n" +
            "\tpublic void setGroupCouponStatus(Integer groupCouponStatus) {\n" +
            "\t\tthis.groupCouponStatus = groupCouponStatus;\n" +
            "\t}\n" +
            "\tpublic Date getWriteOffTime() {\n" +
            "\t\treturn writeOffTime;\n" +
            "\t}\n" +
            "\tpublic void setWriteOffTime(Date writeOffTime) {\n" +
            "\t\tthis.writeOffTime = writeOffTime;\n" +
            "\t}\n" +
            "\tpublic Long getOrderFormId() {\n" +
            "\t\treturn orderFormId;\n" +
            "\t}\n" +
            "\tpublic void setOrderFormId(Long orderFormId) {\n" +
            "\t\tthis.orderFormId = orderFormId;\n" +
            "\t}\n" +
            "\tpublic Long getPosterGoodsCartId() {\n" +
            "\t\treturn posterGoodsCartId;\n" +
            "\t}\n" +
            "\tpublic void setPosterGoodsCartId(Long posterGoodsCartId) {\n" +
            "\t\tthis.posterGoodsCartId = posterGoodsCartId;\n" +
            "\t}\n" +
            "\tpublic Long getTuiKuanShouHouId() {\n" +
            "\t\treturn tuiKuanShouHouId;\n" +
            "\t}\n" +
            "\tpublic void setTuiKuanShouHouId(Long tuiKuanShouHouId) {\n" +
            "\t\tthis.tuiKuanShouHouId = tuiKuanShouHouId;\n" +
            "\t}\n" +
            "\tpublic Long getOrderMealUserId() {\n" +
            "\t\treturn orderMealUserId;\n" +
            "\t}\n" +
            "\tpublic void setOrderMealUserId(Long orderMealUserId) {\n" +
            "\t\tthis.orderMealUserId = orderMealUserId;\n" +
            "\t}\n" +
            "\tpublic String getGroupSkusJson() {\n" +
            "\t\treturn groupSkusJson;\n" +
            "\t}\n" +
            "\tpublic void setGroupSkusJson(String groupSkusJson) {\n" +
            "\t\tthis.groupSkusJson = groupSkusJson;\n" +
            "\t}\n" +
            "\n" +
            "}\n";
}
